package com.flower8.service.impl;

import com.flower8.dao.RecommendDao;
import com.flower8.model.Recommend;
import com.flower8.service.RecommendService;
import com.flower8.utils.PageData;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * @Description:
 * @Author: tanglin
 * @Date: 2019/10/23 11:26
 * @Version: 1.0
 */
@Service
public class RecommendServiceImpl implements RecommendService {

    @Autowired
    private RecommendDao recommendDao;

    /**
     * 查询推荐列表
     * @param pd
     * @return
     * @throws Exception
     */
    @Override
    public List<Recommend> getRecommendList(PageData pd) throws Exception {
        return recommendDao.getRecommendList(pd);
    }

    /**
     * 查询推荐列表数量
     * @param pd
     * @return
     * @throws Exception
     */
    @Override
    public int getRecommendListCount(PageData pd) throws Exception {
        return recommendDao.getRecommendListCount(pd);
    }

    /**
     * 根据推荐id查询
     * @param pd
     * @return
     */
    @Override
    public Recommend getRecommendById(PageData pd) throws Exception {
        return recommendDao.getRecommendById(pd);
    }

    /**
     * 更新推荐
     * @param recommend
     * @throws Exception
     */
    @Override
    @Transactional
    public void updateRecommend(Recommend recommend) throws Exception {
        recommendDao.updateRecommend(recommend);
    }

    /**
     * 删除推荐
     * @param id
     * @throws Exception
     */
    @Override
    @Transactional
    public void deleteRecommend(long id) throws Exception {
        recommendDao.deleteRecommend(id);
    }

    /**
     * 新增推荐
     * @param recommend
     * @throws Exception
     */
    @Override
    @Transactional
    public void addRecommend(Recommend recommend) throws Exception {
        recommendDao.addRecommend(recommend);
    }
}
